package service.impl;

import dao.IRainQualityDao;
import dao.impl.RainQualityDaoImpl;
import entity.RainQuality;
import service.IRainQualityService;

import java.sql.SQLException;
import java.util.List;

public class RainQualityServiceImpl implements IRainQualityService {

    private IRainQualityDao rainQualityDao = new RainQualityDaoImpl();

    @Override
    public List<RainQuality> findAll() throws Exception {
        try {
            System.out.println("RainQualityServiceImpl.findAll()");
            return rainQualityDao.findAll();
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public boolean add(RainQuality rainQuality) throws Exception {
        try {
            int result = rainQualityDao.add(rainQuality);
            return result > 0;
        } catch (SQLException e) {
            throw new Exception("获取雨量时出错" + e.getMessage());
        }
    }

    @Override
    public boolean deleteById(int id) throws Exception {
        try {
            int result = rainQualityDao.deleteById(id);
            return result > 0;
        } catch (SQLException e) {
            throw new Exception("获取雨量时出错" + e.getMessage());
        }
    }
}
